package com.lenovo.gpsautotest;

import android.location.Location;
import android.location.LocationListener;
import android.os.Bundle;
import android.util.Log;

import com.lenovo.gpsautotest.LocationManager.EventBusEvents.LocationStatusEvent;

import org.greenrobot.eventbus.EventBus;

/**
 * @ProjectName: GpsAutoTest
 * @Package: com.lenovo.gpsautotest
 * @ClassName: GpsLocationListener
 * @Description: GpsLocationListener类作用描述
 * @Author: kgzhou
 * @CreateDate: 2019/6/4 16:15
 * @UpdateUser: kgzhou
 * @UpdateDate: 2019/6/4 16:15
 * @UpdateRemark: 更新说明：
 * @Version: 1.0
 */
public class GpsLocationListener implements LocationListener {
    private static final String TAG = GpsLocationListener.class.getSimpleName();

    //当坐标改变时触发此函数，如果Provider传进相同的坐标，它就不会被触发
    @Override
    public void onLocationChanged(Location location) {
        Log.d(TAG, "onLocationChanged: ----------------");
        LocationStatusEvent locationStatusEvent=new LocationStatusEvent();
        locationStatusEvent.setLocation(location);
        EventBus.getDefault().post(locationStatusEvent);
    }

    //
    @Override
    public void onStatusChanged(String provider, int status, Bundle extras) {
        Log.d(TAG, "onStatusChanged: ---------------------");
    }

    //定位开启
    @Override
    public void onProviderEnabled(String provider) {
        Log.d(TAG, "onProviderEnabled: -------------------");
    }

    //定位关闭
    @Override
    public void onProviderDisabled(String provider) {
        Log.d(TAG, "onProviderDisabled: ---------------------");
    }
}
